package cards;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;


public class CardGame extends JFrame implements ActionListener {

	private ImageIcon card1, card2, card3;
	private JButton   shuffle;
	
	public CardGame(){
		setBounds(100, 100, 400, 300);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLayout( null );
		shuffle = new JButton("Cyle cards");
		shuffle.setBounds(125, 200, 150, 30 );
		shuffle.addActionListener( this );
		add( shuffle );
		
		card1 = new ImageIcon("src/cards/CardImages/01a.jpg");
		card2 = new ImageIcon("src/cards/CardImages/01b.jpg");
		card3 = new ImageIcon("src/cards/CardImages/01c.jpg");
		
		setVisible( true );		
	}
	
	public void actionPerformed(ActionEvent arg0) {
		Image oldCard1 = card1.getImage();
		card1.setImage( card2.getImage() );
		card2.setImage( card3.getImage() );
		card3.setImage( oldCard1 );
		repaint();
	}

	public void paint(Graphics g){
		super.paint(g);
		
		g.drawImage( card1.getImage() , 50, 50, null );
		g.drawImage( card2.getImage() , 150, 50, null );
		g.drawImage( card3.getImage() , 250, 50, null );
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new CardGame();
	}
}
